package com.ruoyi.hyg.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hyg.domain.ExamIntro;
import com.ruoyi.hyg.service.IExamIntroService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试前沿Controller
 *
 * @author ruoyi
 * @date 2025-08-13
 */
@RestController
@RequestMapping("/hyg/intro")
public class ExamIntroController extends BaseController
{
    @Autowired
    private IExamIntroService examIntroService;
    
    /**
     * 查询考试前沿列表
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamIntro examIntro)
    {
        startPage();
        List<ExamIntro> list = examIntroService.selectExamIntroList(examIntro);
        return getDataTable(list);
    }
    
    /**
     * 导出考试前沿列表
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:export')")
    @Log(title = "考试前沿", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamIntro examIntro)
    {
        List<ExamIntro> list = examIntroService.selectExamIntroList(examIntro);
        ExcelUtil<ExamIntro> util = new ExcelUtil<ExamIntro>(ExamIntro.class);
        util.exportExcel(response, list, "考试前沿数据");
    }
    
    /**
     * 获取考试前沿详细信息
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examIntroService.selectExamIntroById(id));
    }
    
    /**
     * 新增考试前沿
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:add')")
    @Log(title = "考试前沿", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamIntro examIntro)
    {
        return toAjax(examIntroService.insertExamIntro(examIntro));
    }
    
    /**
     * 修改考试前沿
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:edit')")
    @Log(title = "考试前沿", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamIntro examIntro)
    {
        return toAjax(examIntroService.updateExamIntro(examIntro));
    }
    
    /**
     * 删除考试前沿
     */
    @PreAuthorize("@ss.hasPermi('hyg:intro:remove')")
    @Log(title = "考试前沿", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examIntroService.deleteExamIntroByIds(ids));
    }
}
